home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 3: CDPD 3 / Almathera Ten on Ten - Disc 3: CDPD3.iso / ab20 / unarced / languages / c-manual / tools / p2s.c < prev    next >
C/C++ Source or Header  |  1995-03-17  |  2KB  |  100 lines

  1. /*   P2S (Pointer To Sprite)   AMIGA C MANUAL    Anders Bjerin    */
  2. /*                                                                */
  3. /* This program prints out the Sprite Data of the pointer. It can */
  4. /* also print out the colours, and/or a SimpleSprite structure.   */
  5. /*                                                                */
  6. /* Syntax: P2S [name] [-c] [-s]                                   */
  7. /* name  : name of the sprite. (Default name is "sprite".)        */
  8. /* -c    : print out the colours.                                 */
  9. /* -s    : print out a SimpleSprite structure.                    */
  10.  
  11.  
  12. #include <intuition/intuition.h>
  13.  
  14.  
  15. struct IntuitionBase *IntuitionBase;
  16.  
  17.  
  18. main( argc, argv)
  19. int argc;
  20. char *argv[];
  21. {
  22.   struct Preferences pref;
  23.   int loop;
  24.  
  25.   char name[] = "sprite";
  26.   BOOL colours = FALSE;
  27.   BOOL structure = FALSE;
  28.  
  29.  
  30.  
  31.   /* Open the Intuition Library: */
  32.   IntuitionBase = (struct IntuitionBase *)
  33.     OpenLibrary( "intuition.library", 0 );
  34.   
  35.   if( IntuitionBase == NULL )
  36.     exit(); /* Could NOT open the Intuition Library! */
  37.  
  38.  
  39.  
  40.   /* Check which arguments have been sent: */ 
  41.   for( loop = 1; loop < argc; loop++ )
  42.   {
  43.     /* Name: */
  44.     if( argv[ loop ][0] != '-' )
  45.       strcpy( name, argv[ loop ] );
  46.  
  47.     /* Colours: */
  48.     if( argv[ loop ][0] == '-' && argv[ loop ][1] == 'c' )
  49.       colours = TRUE;
  50.  
  51.     /* Structure: */
  52.     if( argv[ loop ][0] == '-' && argv[ loop ][1] == 's' )
  53.       structure = TRUE;
  54.   }
  55.  
  56.  
  57.  
  58.   /* Get a copy of the Preferences: */
  59.   if( GetPrefs( &pref, sizeof( struct Preferences ) ) == NULL )
  60.   {
  61.     printf( "Could not get a copy of the Preferences!\n" );
  62.     CloseLibrary( IntuitionBase );
  63.     exit();
  64.   }
  65.  
  66.  
  67.  
  68.   /* Print out the colours: */
  69.   if( colours )
  70.     printf( "UWORD %s_colours[3] = { 0x%04x, 0x%04x, 0x%04x };\n\n",
  71.       name, pref.color17, pref.color18, pref.color19 );
  72.  
  73.  
  74.  
  75.   /* Print out the Sprite Data: */
  76.   printf( "UWORD chip %s_data[%d] =\n{\n  0x0000, 0x0000,\n\n",
  77.     name, POINTERSIZE );
  78.  
  79.   for( loop = 2; loop < POINTERSIZE - 2; loop += 2)
  80.     printf( "  0x%04x, 0x%04x,\n",
  81.       pref.PointerMatrix[ loop ],
  82.       pref.PointerMatrix[ loop+1 ] );
  83.  
  84.   printf( "\n  0x0000, 0x0000\n};\n" );
  85.  
  86.  
  87.  
  88.   /* Print out the SimpleSprite structure: */
  89.   if( structure )
  90.   {
  91.     printf( "\nstruct SimpleSprite %s =\n{\n", name );
  92.     printf( "  %s_data,\n  %d,\n  0, 0,\n  -1,\n};\n", name, POINTERSIZE );
  93.   }
  94.  
  95.  
  96.  
  97.   /* Close the Intuition Library: */
  98.   CloseLibrary( IntuitionBase );
  99. }
  100.